package com.zunipe;

import com.zunipe.OreSim.OreSim;
import com.zunipe.config.ZunipeConfig;
import com.zunipe.render.RenderBlockList;
import com.zunipe.render.RenderOutlines;
import com.zunipe.until.KeyBind;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.TimeZone;

public class ZunipeTools implements ModInitializer
{
    public static final MinecraftClient client = MinecraftClient.getInstance();
    public static final Logger LOGGER = LogManager.getLogger("zunipe-tools");
    public static final String MODID = "zunipetools";
    public static boolean PASS = true;
    public static OreSim os = new OreSim();

    @Override
    public void onInitialize()
    {
        //Util.getURLData("https://www.zunipe.xyz/whitelist.txt", "utf-8");
        if (PASS)
        {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+08:00"));
            ZunipeConfig.createOptionConfig();
            ZunipeConfig.loadOptionConfig();
            ZunipeConfig.createConfig();
            ZunipeConfig.loadConfig();
            WorldRenderEvents.LAST.register(RenderOutlines::render);
            RenderBlockList.init();
            new KeyBind();
            new Thread(() ->
            {
                while (true)
                {
                    try
                    {
                        Thread.sleep(5000);
                        ZunipeConfig.saveOptionConfig();
                    } catch (InterruptedException | IOException e)
                    {
                        ZunipeTools.LOGGER.error(e.getMessage());
                    }
                }
            }).start();
        }
    }
}
